package org.xdq.工厂模式;

import org.xdq.工厂模式.impl.Apple;
import org.xdq.工厂模式.impl.Banana;
import org.xdq.工厂模式.impl.Orange;
import org.xdq.工厂模式.impl.Strawberry;

/**
 * 工厂类
 */
public class FruitFactory {


    public final static int TYPE_APPLE =1;
    public final static int TYPE_ORANGE =2;
    public final static int TYPE_BANANA =3;
    public final static int TYPE_Strawberry =4;



    public static Fruit createFreate(int type){
        switch (type){
            case TYPE_APPLE:
                return new Apple();
            case TYPE_ORANGE:
                return new Orange();
            case TYPE_BANANA:
                return new Banana();
            case TYPE_Strawberry:
                return new Strawberry();
            default:
                throw new RuntimeException("本工厂不暂支持的类型："+type);

        }
    }

    private FruitFactory(){}

}
